{extends 'base/site2.html'}
{block name="page_header"}{include file="common/header.html" inline}{/block}
{block name="page_nav"}{include file="common/slide-nav.html" inline}{/block}
{block name="page_styles"}
    <link rel="stylesheet" type="text/css" href="/css/mediation/caseuploadcheck/index.css" />
<style>


</style>
{/block}

{block name="page_section"}


<div class="sessionPage">

    <ul class="nav nav-tabs" style="width:95%;margin: 10px auto;">
        <li {if $line == 1} class="active"{/if}><a href="/workernumber/index?line=1" style="color:#1D2129;font-size: 15px"><b>线路1(移动)</b></a></li>
        <li {if $line == 2} class="active"{/if}><a href="/workernumber/index?line=2" style="color:#1D2129;font-size: 15px"><b>线路2(联通)</b></a></li>
    </ul>
    <div class="page-header">
    <div class="left">
        <!--        <span class="line"></span>-->
        <!--        <strong class="tit">坐席工号</strong>-->
    </div>
    <div class="right">
        <button type="button" data-target="#modal_upload_number" data-toggle="modal" class="btn btn-info textright btn-xs">更新sip账号</button>
        <button type="button" id="sync_number" data-line="{$line}" data-toggle="modal" class="btn btn-info textright btn-xs">同步坐席</button>
    </div>
</div>


    <form method="get" action="" id="form-ele" role="validform" enctype="multipart/form-data" class="small-style">
      <div class="form_row">
        <input type="hidden" name="is_show" class="showmoreishow" value="{if $is_show == 1}1{else}0{/if}">
        <input type="hidden" name="limit" value="{if $query.limit}{$query.limit}{/if}">
        <input type="hidden" id = 'djid' value="">
        <input type="hidden" name="line" id ='line' value="{$line}">
        <div class="form-group col-lg-3 ui-select">
          <label for="exampleInputName2"  class="col-sm-3 control-label">调解部门:</label>
          <div class="col-sm-7">
              <select class="form-control" name="mediationOrganId">
                  <option class="u144_input_option"  {if $query.mediationOrganId=='0'}selected="selected"{/if} value="0">全部</option>
                  {foreach from=$mediationOrgan item=item key=key}
                      <option class="u144_input_option" {if $query.mediationOrganId==$key}selected="selected"{/if} value="{$key}">{$item.name}</option>
                  {/foreach}
              </select>
          </div>
        </div>
        <div class="form-group col-lg-3 ui-select">
          <label for="exampleInputName2"  class="col-sm-3 control-label">调解员:</label>
          <div class="col-sm-7">
              <select class="form-control" id="is_contrast" name="mediator" role-ele="mediator">
                  <option class="u144_input_option" {if $query.mediator==0}selected="selected"{/if} value="0">全部</option>
                  {foreach from=$mediator item=item }
                      {if $item.id != 1}
                          <option class="u144_input_option" {if $query.mediator == $item.name}selected="selected"{/if} value="{$item.name}">{$item.name}</option>
                      {/if}
                  {/foreach}
              </select>
          </div>
        </div>
        <div class="start-hide col-lg-12" data-isshow="{if $is_show == 1}true{else}false{/if}" {if $is_show == 1}style="padding:0px;"{else}style="padding:0px;display:none;"{/if}>
        </div>
        <div class="form-group col-lg-4 ui-select">
            <div class="col-lg-4" >
                <button class="btn btn-primary col-lg-8 shousuoBtn"><span class="nav-icon glyphicon glyphicon-search" aria-hidden="true" style="margin-right: 2px"></span>查询</button>
            </div>
            <div class="col-lg-4">
                <a type="button" href="/workernumber/index" class="btn btn-default col-lg-8" ><span class="nav-icon glyphicon glyphicon-refresh" aria-hidden="true" style="margin-right: 2px"></span>重置</a>
            </div>
{*            <div class="col-lg-4">*}
{*                <button  class="btn btn-info col-lg-8 data_upload"><span class="nav-icon glyphicon glyphicon-repeat" aria-hidden="true" style="margin-right: 2px"></span>更新</button>*}
{*            </div>*}
        </div>
        <div class="ui-select"></div>
      </div>
    </form>
    <div style="width: 95%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    overflow-x: scroll;">
        {if  $line == 1}
        <span style="color: red">分机注册地址：pbx.rygx2.unitcc.com:6064；</span>
        {else}
        <span style="color: red">分机注册地址：pbx.rygx2.unitcc.com:6065；</span>
        {/if}
    <table class="table table-striped table-bordered table-hover text-nowrap" id="tab">
        <thead>
        <tr>
            <th><input type="checkbox" class="checkall" style="vertical-align: text-bottom"></th>
            <th>调解部门</th>
            <th>调解员</th>
            <th>坐席号</th>
            <th>分机号</th>
            <th>外显号</th>
            <th>外显名片</th>
            <th>分机密码</th>
            <th>运营商技能组</th>

        </thead>
    <tbody>
    {if $arrList}
        {foreach from=$arrList item=item name=foo}
            <tr>
                <td> <input name="checkItem" class="j-check" type="checkbox" value="{$item.id}"></td>
                <td>{if $item['mediationOrganId']}{$mediationOrgan[$item['mediationOrganId']]['name']}{else}--{/if}</td>
                <td class="nowrap">{if $item.mediator}{$item.mediator}{else}--{/if}</td>
                <td>{$item.workerId}</td>
                <td class="nowrap">{$item.extnumber}</td>
                <td class="nowrap">{$item.outNumber}</td>
                <td class="nowrap">{$numCard[$item.outNumber]}</td>
                <td class="nowrap">{$item.extnumberPswd}</td>
                <td class="nowrap">{$item.displayName}</td>

            </tr>
        {/foreach}
    {/if}
    </tbody>
    </table>
        <div class="col-lg-12 pad-no mr-b20" style="margin:0;">
<!--            <button class="btn btn-danger delnumber" allocate-type="2" data-toggle="modal" data-target="#allocate_origin">删除</button>-->
            <button class="btn btn-danger" allocate-type="2" id='bindCallNum' data-toggle="modal" data-target="#bind_call_num">绑定外显号码</button>
        </div>
    </div>
    <div class="pad-no" style="margin-top: 10px;">
{*        <input type="button" value="全选" class="btn btn-default btn-xs" id="selectAll">*}
{*        <input type="button" value="反选" class="btn btn-default btn-xs" id="reverse">*}
{*        <input type="button" value="转文字" class="btn btn-default btn-xs transferAll" data-url="/callout/transferText">*}
    </div>

    <div class="clearfix pad-no text-nowrap" style="margin-top: 20px;">
        {include file="base/pagenav.html"  action="/workernumber/index?line={$line}" pagenum=$curPageNum inline}
        <select class="form-control" id="paglimit" style="float:right;margin:0 10px;width: auto;margin-top: -5px;">
            <option value="limit=10" {if $query.limit==10}selected="selected"{/if}>10条/页</option>
            <option value="limit=20" {if $query.limit==20}selected="selected"{/if}>20条/页</option>
            <option value="limit=50" {if $query.limit==50}selected="selected"{/if}>50条/页</option>
            <option value="limit=100" {if $query.limit==100}selected="selected"{/if}>100条/页</option>
        </select>
        <span style="float:right;">共 {$totalnum} 条</span>
    </div>
    <div class="modal fade" id="modal_upload_number" tabindex="-1" role="dialog" aria-labelledby="confirmLabel">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="exampleModalLabel">更新坐席 - 分机号及密码</h4>
                </div>


                <div class="clearfix modal-body">
                    <div class="tab-content">

                            <form  class="form-inline" id="importNumber_form">

                            <div class="form-group col-sm-12 morenumber" id="bath-add" style="margin-top:15px;">
                                <div class="form-group col-lg-12 ui-select" style="display: flex;justify-content: center;align-items:center;">
                                    <div style="color:#93b6e7;display: flex;flex-direction: column;align-items: center;margin: 20px 0;position: relative;">
                                        <i class="glyphicon glyphicon-file" style="font-size: 35px;"></i>
                                        <span>上传文档</span>
                                        <input type="file" class="uploadFile" id="upfile" style="opacity: 0;position: absolute;left: 0;top: 0;right: 0;bottom: 0;cursor: pointer;">
                                    </div>
                                </div>
                            </div>
                            </form>
                        </div>
                </div>
                <div class="modal-footer">
                    <a type="button" href="/workernumber/downTemplate" style="float: left;" class="btn btn-default left downTemplate">下载模板</a>
                    <button type="button" id="numberSubmit" class="btn btn-primary">确定</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="bind_call_num" tabindex="-1" role="dialog" aria-labelledby="refusal_modal" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="exampleModalLabel">绑定外显号码</h4>
            </div>
            <div class="modal-body">
                <form id="entrustExpireTime_form">
                    <div class="form_dialog form-group col-lg-10 ui-select">
                        <label for="exampleInputName2"  class="col-sm-3 control-label">外显号码:</label>
                        <div class="col-sm-9">
                            <select class="form-control" id="call_num" name="call_num">
                                <option value="" >——请选择——</option>
                                {foreach from=$callNum item=info}
                                <option class="u144_input_option" value="{$info}">{$info}-{$numCard[$info]}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>

                    <input type="hidden" value="" id="bind_work_ids" name="bind_work_ids">

                </form>

            </div>
            <div class="modal-footer" style="text-align: center;">
                <button type="button" class="btn btn-default" id="fpclosebtn" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary distribution_bindCallNum">确定</button>
            </div>


        </div>
    </div>
</div>

</div>

{/block}
{block name="page_scripts"}
<script type="text/javascript" src="/js/mediation/workernumber/index.min.js" init="mediation/workernumber/index"></script>

    <script type="text/javascript">
        $("#bindCallNum").on("click",function(){
            var arrbtn = [];
            $(".j-check:checked").each(function (index, ele) {
                //遍历所有复选框，然后取值进行 !非操作
                if ($(this).prop("checked")) {
                    arrbtn.push($(this).val());
                }
            })
            if(arrbtn.length==0){
                toastr.error('请选择案件');
                return false;
            }
            var ids=arrbtn.toString();
            $("#bind_work_ids").val(ids);

            $("#bind_call_num").show();
        });
        function GetQueryString(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r!=null)return  unescape(r[2]); return null;
        }
        $('body')
            .on('change','#paglimit', function(){
            console.log()
            var mediationOrganId = GetQueryString('mediationOrganId');
            var paglimit = GetQueryString('limit');
            var val =  $(this).val();
            if(!mediationOrganId){
                if(!paglimit){
                    window.location = window.location.href+'?'+val;
                } else{
                    window.location = window.location.href.replace('limit='+paglimit,val);
                }
            }else{
                if(!paglimit){
                    window.location = window.location.href+'&'+val;
                } else{
                    window.location = window.location.href.replace('limit='+paglimit,val);
                }
            }
        })
            .on('click', '.distribution_bindCallNum', function(){
                if(lockfas)return;
                lockfas = true;
                arrcaseid = [];
                if($("#bind_work_ids").val()==0){
                    toastr.error('请选择坐席');
                    return false;
                }
                $.ajax({
                    url:"/workernumber/bindCallNum",
                    method:"post",
                    data:{
                        'ids': $("#bind_work_ids").val(),
                        'callNum' : $("#call_num").val(),
                    },
                    success:function(res){
                        if(res.code==200){
                            lockfas = false;
                            toastr.success("绑定成功");
                            setTimeout(function(){
                                window.location.reload();
                            },2000)
                        }else{
                            lockfas = false;
                            toastr.error(res.message);

                        }
                    }
                })
                lockfas = false;

            })

    </script>
{/block}
